package app.auto.runner.base.utility;

import androidx.annotation.NonNull;

/**
 * Author：何送军
 * creation time：2018/4/5
 **/
public class ZhUtil {
    @NonNull
    public static String catZh(Object result) {
        String ch = "";
        for (int i = 0; i < result.toString().length(); i++) {
            if (isChinese(result.toString().charAt(i))) {
                ch += result.toString().charAt(i);
            }
        }
        return ch;
    }
    public static boolean isChinese(char c) {

        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);

        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS

                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS

                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A

                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION

                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION

                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {

            return true;

        }

        return false;

    }
}
